#define VRX A0
#define VRY A1
#define SW  12

int px = 0;
int py = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(SW, INPUT_PULLUP);

  digitalWrite(LED_BUILTIN, LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
  px = analogRead(VRX);
  py = analogRead(VRY);
  Serial.print("px: ");
  Serial.print(px);
  Serial.print("  py: ");
  Serial.println(py);

  // 假如按键被按下，翻转 LED
  if (digitalRead(SW) == LOW){
    // 消除抖动
    delay(20);
    if (digitalRead(SW) == LOW){
      digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
    }
  }

  delay(200);
}
